﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Pg.BioMedics.SDR.ServiceAgents.Configuration
{
    /// <summary>
    /// Represetns collection of service endpoints
    /// </summary>
    public sealed class EndpointsElementCollection : ConfigurationElementCollection
    {
        #region Properties

        /// <summary>
        /// Gets active endpoints
        /// </summary>
        internal IList<string> ActiveEndpoints
        {
            get
            {
                return (from key in BaseGetAllKeys()
                        let endpoint = BaseGet(key) as EndpointElement
                        where endpoint.Enabled
                        select endpoint.EndpointName).ToList();
            }
        }

        #endregion

        #region Overriden methods

        protected override ConfigurationElement CreateNewElement()
        {
            return new EndpointElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return (element as EndpointElement).EndpointName;
        }

        #endregion
    }
}
